﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AccessConfigurator.control;

namespace AccessConfigurator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void tbcode_TextChanged(object sender, EventArgs e)
        {
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the '_sam_eduDataSet.licensekey' table. You can move, or remove it, as needed.
            this.licensekeyTableAdapter.Fill(this._sam_eduDataSet.licensekey);

        }

        private void btnEnter_Click(object sender, EventArgs e)
        {
            bool success = false;
            string featurename = tbfeaturename.Text;
            string code = tbcode.Text;
            /*   if (Convert.ToBoolean(int.Parse(code)== 1) || int.Parse(tbcode.Text) % 2 !=1) 
                {
                    bool status = Configurator.requestInsertFeature(featurename, code);
                    if (status == true)
                    {
                        MessageBox.Show("Successful");
                    }
                }
                else
                {
                    MessageBox.Show("Validation fail");
                }*/

            for (int i = 1; i <= 64; i *= 2)
            {
                if (int.Parse(code) == i)
                {

                    success = true;
                    break;

                }

                else
                {
                    success = false;

                }

            }
            if (success == true)
            {
                bool status = Configurator.requestInsertFeature(featurename, code);
                if (status == true)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("An error occured");
                }
            }
            else
            {
                MessageBox.Show("Validation fail");
            }
        }

      

      
    }
}
